from turtle import st
from typing import List

from pydantic_settings import BaseSettings
import os

# 获取项目路径
def get_project_root():
    return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

class Settings(BaseSettings):
    DOC_PATHS: List[str] = ["/docs", "/redoc", "/openapi.json", "/"]
    DATABASE_URL: str = "mysql+mysqlconnector://root:xyncsyd749518.ZYD@192.168.31.100:13306/ccadmin"
    Env: str = "dev" or "prod"
    RSA_PRIVATE_KEY_PATH: str = os.path.join(get_project_root(), "core/private_key.pem")
    RSA_PUBLIC_KEY_PATH: str = os.path.join(get_project_root(), "core/public_key.pem")
    API_ENCRYPT: bool = False
    API_DECRYPT: bool = False

    
    ALGORITHM: str = "RS256"  # 算法
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30  # 过期时间（分钟）
    # 需要跳过token校验的路径白名单
    AUTH_WHITELIST: List[str] = [
        "/api/admin/users/login",  # 登录接口
        "/api/admin/users",        # 创建用户接口（假设公开注册）
        "/docs",                   # Swagger文档
        "/redoc",
        "/openapi.json",
        "/api/admin/users/login"
    ]

    class Config:
        env_file = ".env"

settings = Settings()


if __name__ == '__main__':
    print(settings.DATABASE_URL)
    print(settings.RSA_PRIVATE_KEY_PATH)
    print(get_project_root())


